# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Médéric Boquien <mboquien@free.fr>

_pkg=extension-helpers
pkgname=python-${_pkg}
pkgver=1.1.0
pkgrel=1
pkgdesc="Utilities for building and installing packages with compiled extensions"
arch=(any)
url="https://github.com/astropy/extension-helpers"
license=(BSD)
depends=(python-setuptools)
makedepends=(python-build python-installer python-setuptools-scm python-wheel)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/e/${_pkg}/${_pkg}-${pkgver}.tar.gz)
sha256sums=('49460c78a3f8d1f8cec174479f5e85ad445948ccc416033c5aa3e6ddf2c50229')

build() {
  cd ${_pkg}-${pkgver}
  python -m build --wheel --no-isolation
}

check() {
  cd ${_pkg}-${pkgver}/build/lib/extension_helpers
  # Some strange failures but no time to investigate
  pytest -vv --color=yes || echo "Tests failed"
}

package() {
  cd ${_pkg}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  rm -r "${pkgdir}"$(python -c "import site; print(site.getsitepackages()[0])")/extension_helpers/tests
  install -Dm644 LICENSE.rst -t "${pkgdir}"/usr/share/licenses/$pkgname/
}
